package it.unical.mat.aec.gui;

import java.util.ArrayList;

import it.unical.mat.aec.model.Studente;
import it.unical.mat.aec.model.Test;

import javax.swing.table.AbstractTableModel;

public class TestValutationTableModel extends AbstractTableModel {
	
	private ArrayList<Test> tests;
	
	private String columnName[]={"Matricola","Cognome","Nome","Punteggio"};
	

	public TestValutationTableModel(ArrayList<Test> tests) {
		this.tests = tests;
	}
	
	public TestValutationTableModel(Test test) {
		this.tests = new ArrayList<Test>();
		tests.add(test);
	}

	@Override
	public int getColumnCount() {
		return columnName.length;
	}
	
	@Override
	public String getColumnName(int index) {
		return columnName[index];
	}

	@Override
	public int getRowCount() {
		return tests.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		if(columnIndex==0)
			return tests.get(rowIndex).getStudente().getMatricola();
		else if(columnIndex==1)
			return tests.get(rowIndex).getStudente().getCognome();
		else if(columnIndex==2)
			return tests.get(rowIndex).getStudente().getNome();
		else if(columnIndex==3)
			return tests.get(rowIndex).getPunteggio();
		return null;
	}

}
